import 'package:backend.core/core/domain/entities/user_role.dart';
import 'package:equatable/equatable.dart';

const kAdminUserRoleValue = 'admin';
const kEndUserRoleValue = 'end_user';

class ApiUserRoleDto extends Equatable {
  const ApiUserRoleDto._internal({
    required this.roleString,
  });

  final String roleString;

  @override
  List<Object?> get props {
    return [
      roleString,
    ];
  }

  factory ApiUserRoleDto.fromEntity(UserRole role) {
    late final String roleString;

    if (role.isAdmin) {
      roleString = kAdminUserRoleValue;
    } else if (role.isEndUser) {
      roleString = kEndUserRoleValue;
    }

    return ApiUserRoleDto._internal(
      roleString: roleString,
    );
  }

  @override
  String toString() {
    return roleString;
  }
}
